﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace Pro260Website.HtmlHelpers
{
    public static class ImageActionLinkHelper
    {
        public static MvcHtmlString ImageActionLink(this AjaxHelper helper, string imageUrl, string altText, string title, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, string hId, string hClass, string hStyle)
        {
            var builder = new TagBuilder("img");
            var spanBuilder = new TagBuilder("span");
            spanBuilder.AddCssClass("title coolBlack");
            spanBuilder.SetInnerText(title);
            builder.MergeAttribute("id", hId);
            builder.MergeAttribute("class", hClass);
            builder.MergeAttribute("style", hStyle);
            builder.MergeAttribute("src", imageUrl);
            builder.MergeAttribute("alt", altText);
            builder.InnerHtml = spanBuilder.ToString();
            var link = helper.ActionLink("[replaceme]", actionName, controllerName, routeValues, ajaxOptions).ToString();
            //<span class="title coolBlack">@game.Name</span>
            return MvcHtmlString.Create(link.Replace("[replaceme]", builder.ToString()));
        }

    }
}